﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Logging;

namespace PMS.Data.EntityMap.Logging
{
    /// <summary>
    /// Represents a log mapping configuration
    /// </summary>
    public partial class LogggerMap : PMSEntityTypeConfiguration<Log>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<Log> builder)
        {
            builder.ToTable("sys_log");
            builder.HasKey(log => log.Id);

            builder.Property(log => log.LogLevel).HasMaxLength(32);
            builder.Property(log => log.LogMessage).HasMaxLength(int.MaxValue);
            builder.Property(log => log.IpAddress).HasMaxLength(64);
            builder.Property(log => log.PageUrl).HasMaxLength(500);
            builder.Property(log => log.ReferrerUrl).HasMaxLength(500);

            builder.Ignore(log => log.IsActive);
            builder.Ignore(log => log.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
